﻿from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp                                        
from google.appengine.ext.webapp.util import run_wsgi_app      
from google.appengine.api import users
from entities import *
def signin(self):
    user = users.get_current_user()
    if user:  # signed in already
        signready = ('Xin chào <em>%s</em>! [<a href="%s">Thoát</a>]' % (
            user.nickname(), users.create_logout_url('/')))
        #self.response.out.write('Xin chào <em>%s</em>! [<a href="%s">Thoát</a>]' % (
        #    user.nickname(), users.create_logout_url(self.request.uri)))
        return signready
    else:     # let user choose authenticator
        #self.response.out.write('Xin chào bạn đến với trang web! Đăng nhập tại: ')
        #for p in openIdProviders:
        ##    p_name = p.split('.')[0] # take "AOL" from "AOL.com"
         #   p_url = p.lower()        # "AOL.com" -> "aol.com"
         #   self.response.out.write('[<a href="%s">%s</a>]' % (
        #        users.create_login_url(dest_url=p_url), p_name))
        greeting = ("<a href=\"%s\">Đăng nhập/Đăng ký</a>." % users.create_login_url("/"))
        #self.response.out.write("<html><body>%s</body></html>" % greeting)
        return greeting
def insertGenre(name, description):
    genre = Genre()
    genre.name = unicode(name,'utf-8')
    genre.description = unicode(description,'utf-8')
    genre.put()
    return genre	
def init_start():
    #VaiTro.Add()
    #NguoiDung.Add("sunrises@gmail.com","http://test.net",6001)
    #TrangThai.Add(Entities.GetKey(),'Vua nhap')
    #LoaiHinh.Add('Ban thoi gian')
    #DoiTuong.Add(Entities.GetKey(),'Nguoi binh thuong',None,None)
    #MucLuong.Add('Thoa thuan')
    
    #NganhNghe.Add(Entities.GetKey(),'Ban may tinh',77)
    #QuiMo.Add('Tu 1 - 5 nguoi')
    #TinhThanh.Add('Ha Noi')
    #CapBac.Add('Sinh vien thuc tap')
    #NganhNghe.Add(Entities.GetKey(),'Ban may tinh', 19001)
    CapBac.Add('Sinh vien thuc tap')